import os
import sys

from weasyprint import HTML, CSS

platform = 'win' if sys.platform == 'win32' else 'linux'

current = os.path.abspath(os.path.dirname(__file__))

pdf = HTML(
    filename=os.path.join(current, '..', 'index.html'),
    encoding='utf-8'
)

version = sys.version_info
file = os.path.join(
    current,
    'python{}{}{}_{}.pdf'.format(
        version.major,
        version.minor,
        version.micro,
        platform
    )
)

pdf.write_pdf(
    file,
    stylesheets=[
        CSS(string='h1{color:red;}')
    ]
)
